<?php
	require_once '../../model/global.inc.php';  
        if(!isset($_SESSION['logged_in'])) {
             echo "<script>alert('Please login');</script>";
        }
        else {
            $user = unserialize($_SESSION['user']);
            $memid = $user->memid;
            $result = mysql_query("SELECT numbid FROM tblmember where memid = '$memid'");

            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
                  $numbid = $row["numbid"];
            }
            if($numbid<=10){
                echo "<script>alert('Please insert coin');</script>";
            }
            else{
                $pro_id = $_POST['pro_id'];
                $bid_prince = $_POST['price_bid'];
                $prince = (double)($bid_prince) + 0.1;
                $memid = $_POST['memid'];    
                $numbid1 = $numbid - 1;
                
                $sql = "UPDATE tblmember SET numbid = $numbid1 WHERE memid = '$memid'";  
		mysql_query($sql) or die(mysql_error());  
                
                $data['memid'] = $memid;
                $data['bid_price'] = $prince;
                $data['pro_id'] = $pro_id;
                $data['price_bid'] = $prince;

                $pro = new Pro($data);
                $pro->save();
                echo "<script>upCount();</script>";
            }
        }
?>
